home *** CD-ROM | disk | FTP | other *** search
/ Enter 2006 September / Enter 09 2006.iso / Internet / SpamExperts Home 1.1 / SpamExperts Home.exe / lib / spamexperts.modules / persistent / mapping.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2006-07-14  |  2.9 KB  |  88 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.4)
  3.  
  4. '''Python implementation of persistent base types
  5.  
  6. $Id: mapping.py 40332 2005-11-22 21:15:25Z tlotze $'''
  7. import persistent
  8. from UserDict import UserDict
  9.  
  10. class PersistentMapping(UserDict, persistent.Persistent):
  11.     '''A persistent wrapper for mapping objects.
  12.  
  13.     This class allows wrapping of mapping objects so that object
  14.     changes are registered.  As a side effect, mapping objects may be
  15.     subclassed.
  16.  
  17.     A subclass of PersistentMapping or any code that adds new
  18.     attributes should not create an attribute named _container.  This
  19.     is reserved for backwards compatibility reasons.
  20.     '''
  21.     __super_delitem = UserDict.__delitem__
  22.     __super_setitem = UserDict.__setitem__
  23.     __super_clear = UserDict.clear
  24.     __super_update = UserDict.update
  25.     __super_setdefault = UserDict.setdefault
  26.     __super_pop = UserDict.pop
  27.     __super_popitem = UserDict.popitem
  28.     
  29.     def __delitem__(self, key):
  30.         self._PersistentMapping__super_delitem(key)
  31.         self._p_changed = 1
  32.  
  33.     
  34.     def __setitem__(self, key, v):
  35.         self._PersistentMapping__super_setitem(key, v)
  36.         self._p_changed = 1
  37.  
  38.     
  39.     def clear(self):
  40.         self._PersistentMapping__super_clear()
  41.         self._p_changed = 1
  42.  
  43.     
  44.     def update(self, b):
  45.         self._PersistentMapping__super_update(b)
  46.         self._p_changed = 1
  47.  
  48.     
  49.     def setdefault(self, key, failobj = None):
  50.         if not self.has_key(key):
  51.             self._p_changed = 1
  52.         
  53.         return self._PersistentMapping__super_setdefault(key, failobj)
  54.  
  55.     
  56.     def pop(self, key, *args):
  57.         self._p_changed = 1
  58.         return self._PersistentMapping__super_pop(key, *args)
  59.  
  60.     
  61.     def popitem(self):
  62.         self._p_changed = 1
  63.         return self._PersistentMapping__super_popitem()
  64.  
  65.     
  66.     def __iter__(self):
  67.         return iter(self.data)
  68.  
  69.     
  70.     def __getstate__(self):
  71.         state = { }
  72.         state.update(self.__dict__)
  73.         state['_container'] = state['data']
  74.         del state['data']
  75.         return state
  76.  
  77.     
  78.     def __setstate__(self, state):
  79.         if state.has_key('_container'):
  80.             self.data = state['_container']
  81.             del state['_container']
  82.         elif not state.has_key('data'):
  83.             self.data = { }
  84.         
  85.         self.__dict__.update(state)
  86.  
  87.  
  88.